package com.zyasdk.service;

import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;

import com.zyasdk.enums.AdType;
import com.zyasdk.util.AppInfoUtil;
import com.zyasdk.util.SP;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 */
public class ADService extends BaseService {

    public ADService(Context context) {
        super(context);
    }

    public void GetNewVersions(Handler handler, String pck, String channel,
                               String packid, String language, AdType adType, String pBindKey) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        String other = SP.getInstance().get(context, "chapingdata");
        if (other.equals("-1") || TextUtils.isEmpty(other)) {
            params.add(new BasicNameValuePair("PropackId", other));
        } else {
            params.add(new BasicNameValuePair("PropackId", other));
        }
        params.add(new BasicNameValuePair("PBindKey", pBindKey));
        params.add(new BasicNameValuePair("packages", pck));
        params.add(new BasicNameValuePair("channels", channel));
        params.add(new BasicNameValuePair("imei", AppInfoUtil.getIMEI(context)));
        params.add(new BasicNameValuePair("imsi", AppInfoUtil.getIMSI(context)));
        params.add(new BasicNameValuePair("packid", packid));
        params.add(new BasicNameValuePair("language", language));
        params.add(new BasicNameValuePair("issdk", "1"));
        params.add(new BasicNameValuePair("spread", adType.getType() + ""));// 获取类型
        params.add(new BasicNameValuePair("index", "10"));// 每次最多取十条数据
        //Log.e("ADService", "请求广告数据: "+params);
        ServiceTask.addTask(GetAPIUrl("GetAdverts"), params, 1, handler, adType);
//        new GetServerValue(context).connet(GetAPIUrl("GetAdverts"), params, 1, handler, adType);
//        ServiceTask.addTask(StaticSetting.BenDi, params, 1, handler, adType);
    }
}
